<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <link rel="shortcut icon" href="../../src/images/bitbug_favicon.ico" type="image/x-icon">
  <meta name="keywords" content="your keywords">
  <meta name="description" content="your description">
  <meta name="author" content="author,email address">
  <meta name="robots" content="index,follow">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="renderer" content="ie-stand">
  <title>仁和区党群服务一号通暨群众意见受理中心</title>
  <link rel="stylesheet" href="../../src/js/libs/laypage/skin/laypage.css">
  <link rel="stylesheet" href="../../src/css/base.css">
  <link rel="stylesheet" href="../../src/css/common.css">
  <link rel="stylesheet" href="../../src/css/tpl.css">
  <style>
    .nd_container {
      margin-top: 40px;
    }

    .nd_container .title {
      text-align: center;
      font-size: 24px;
      font-weight: bold;
      margin-bottom: 20px;
    }

    .nd_container .sub_title {
      font-size: 16px;
      color: #999;
      margin-right: 20px;
      margin-bottom: 30px;
      text-align: center;
    }

    .nd_container .content img {
      clear: both;
      margin-bottom: 15px;
      width: 100%;
      float: left;
    }

    .nd_container .content p {
      line-height: 1.5em;
      font-size: 16px;
      color: #666;
      text-indent: 2em;
      margin: 20px 0;
    }

    #div_collect {
      border: 1px solid #eed8c3;
      width: 60px;
      height: 25px;
      text-align: center;
      line-height: 25px;
      cursor: pointer;
      background-color: #ffe5d0;
      float: right;
      margin: 30px 0px;
      color: #a2644d;
    }
  </style>
  <script src="../../src/js/libs/es5-shim.min.js"></script>
  <script src="../../src/js/libs/es5-sham.min.js"></script>
  <script src="../../src/js/libs/json3.min.js"></script>
</head>

<body>
  <div class="page">
    <div id="header"></div>

    <div class="menu-bar">
      <div class="container">
        <span><span class="crumb-name">当前你的位置：</span>><span>
                <a class="" href="../Home">首页</a>>
                </span>
        <span>最新资讯</span>
      </div>
    </div>
    <!--正文-->
    <div class="mid_container nd_container clearfix" id="detail_html">

    </div>
  </div>
  <div id="footer"></div>

  <script id="detail_tpl" type="text/html">
    <div class="title">{{data.title}}</div>
    <div class="sub_title">{{data.origin}} {{data.publishtime}}</div>
    <div class="content"></div>
    <div id="div_collect" type="{{data.iscllect}}" class="js_collect">
      {{if data.iscllect == 0}}收藏{{/if}} {{if data.iscllect == 1}}已收藏{{/if}}
    </div>
  </script>
  <script src="../../src/js/libs/jquery.1.12.4.js"></script>
  <script src="../../src/js/libs/template-web.js"></script>
  <script src="../../src/js/base/common.js"></script>
  <script>
    var params = {
      userid: null,
      newsid: window.location.href.split('?')[1].split('=')[1]
    }
    var pageindex = 2

    if (document.cookie) {
      params.userid = document.cookie.split(";")[1].split("=")[1]
    }

    $.ajax({
      url: 'http://221.10.2.222:5680/api/ow/News/0/' + params.newsid,
      type: "GET",
      dataType: "json",
      success: function (res) {
        console.log(res)
        var data = {
          data: res
        }
        var detail = template('detail_tpl', data)
        document.getElementById('detail_html').innerHTML = detail;
        $('.content').html(res.content)
      }
    })

    $(document).on('click', '.js_collect', function () {
      if (!params.userid) {
        return alert('请登录！')
      }
      var is_collect = $(this).attr('type'),
        type = 1
      var url = "http://221.10.2.222:5680/api/ow/News/Collect"
      if (is_collect == 1) {
        url = "http://221.10.2.222:5680/api/ow/News/DeleteCollect"
        type = 0;
      }
      var data = {
        "consumersid": params.userid,
        "newsid": params.newsid
      }
      collect(data)
      if (userid) {}
    })

    function collect(data) {
      $.ajax({
        url: 'http://221.10.2.222:5680/api/ow/News/0/' + id,
        type: "GET",
        dataType: "json",
        data: data,
        success: function (res) {
          if (data.result > 0) {
            if (type == 1) {
              $('#div_collect').html('已收藏')
              $('#div_collect').attr('type', '1')
            } else {
              $('#div_collect').html('收藏')
              $('#div_collect').attr('type', '0')
            }
          }
        }
      })
    }
  </script>
</body>

</html>